import 'package:flutter/material.dart';
import 'package:flutter1911/bean/category_child_bean_result.dart';
import 'package:flutter1911/bean/category_goods_list_bean_result.dart';

class CategoryProvider with ChangeNotifier {
  List<CategoryChildBean> childCategoryList = [];
  List<CategoryGoods> categoryGoodsList = [];
  int page = 1; //通过页码来判断是否切换到第一页,同时可以使用page++来加载更多
  int parentIndex = 0; //左侧一级分类的下标
  int childIndex = 0; //二级分类的下标

  changeParentIndex(index) {
    parentIndex = index;
    notifyListeners();
  }

  changeChildIndex(index) {
    childIndex = index;
    notifyListeners();
  }

  setChildCategory(list) {
    childCategoryList = list;
    notifyListeners();
  }

  setCategoryGoodsList(list) {
    categoryGoodsList = list;
    notifyListeners();
  }

  //增加page的方法
  addPage() {
    page++;
    notifyListeners();
  }

  //设置配置归1的方法
  rePage() {
    page = 1;
    notifyListeners();
  }
}
